//
//  AnimatedButtonExample
//  Russell Lowke, June 30th 2013
//
//  Copyright (c) 2013 Lowke Media
//  see http://www.lowkemedia.com for more information
//  see http://code.google.com/p/lowke-buttoncontroller/ for code repository
//
//  Permission is hereby granted, free of charge, to any person obtaining a 
//  copy of this software and associated documentation files (the "Software"), 
//  to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//  and/or sell copies of the Software, and to permit persons to whom the 
//  Software is furnished to do so, subject to the following conditions:
// 
//  The above copyright notice and this permission notice shall be included in 
//  all copies or substantial portions of the Software.
// 
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
//  DEALINGS IN THE SOFTWARE. 
//
//

package
{
    import com.lowke.buttonController.ButtonController;
    
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    
    [SWF (width="400", height="400", backgroundColor="#888888", frameRate="30")]
    public class AnimatedButtonExample extends Sprite
    {
        private var _animatedButtonClip:MovieClip;
        private var _animatedButton:ButtonController;
        
        public function AnimatedButtonExample()
        {
            _animatedButtonClip = new BallButton();
            _animatedButtonClip.x = stage.stageWidth/2;
            _animatedButtonClip.y = stage.stageHeight/2;
            addChild(_animatedButtonClip);
            
            _animatedButton = new ButtonController(_animatedButtonClip);
            _animatedButton.fps = 24;       // animate button at 24 fps NOT the stage frameRate (30 fps)
            _animatedButton.rolloverSound = new OpenSound();
            _animatedButton.rolloutSound = new CloseSound();
            _animatedButton.clickSound = new AttackSound();
            _animatedButton.addWeakListener(MouseEvent.CLICK, buttonClicked);
        }
        
        private function buttonClicked(event:MouseEvent):void
        {
            trace("buttonClicked()");
        }
    }
}